#include<iostream>
using namespace std;
int Getbottlecount(int n)
{
    int sum = 0;
    while (n >= 3)
    {
        int x = n / 3;
        sum += x;
        n %= 3;
        n += x;
        if (n == 2)
            sum++;
    }
    return sum;
}
int main()
{
    int n = 0;
    while (cin >> n)
    {
        if (n == 0)
            break;
        cout << Getbottlecount(n) << endl;
    }
    return 0;
}